<template>
	<view class="goods-list" :data-theme="themeStyle" :style="{ backgroundColor: value.backgroundColor, padding: value.paddingUpDown * 2 + 'rpx 0' }">
		<ns-goods-item-row :value="goodsList" @toDetail="toDetail" :showInfor="value"></ns-goods-item-row>
		<!-- <ns-goods-item-col :value="goodsList" @toDetail="toDetail"></ns-goods-item-col> -->
	</view>
</template>

<script>
import globalConfig from '@/common/js/golbalConfig.js';
import nsGoodsItemRow from '@/components/ns-goods-item/ns-goods-item-row.vue';
// import nsGoodsItemCol from '@/components/ns-goods-item/ns-goods-item-col.vue'
export default {
	name: 'diy-goods-list',
	components: {
		// nsGoodsItemCol,
		nsGoodsItemRow
	},
	props: {
		value: {
			type: Object,
			default: () => {
				return {};
			}
		}
	},
	data() {
		return {
			goodsList: []
		};
	},
	mixins: [globalConfig],
	created() {
		this.getGoodsList();
	},
	methods: {
		getGoodsList() {
			var data = {
				page: 1,
				page_size: this.value.goodsCount
			};
			if (this.value.sources == 'category') {
				data.category_id = this.value.categoryId;
				data.category_level = 1;
			} else if (this.value.sources == 'diy') {
				data.goods_id_arr = this.value.goodsId.toString();
			}
			this.$api.sendRequest({
				// url: '/api/goodssku/page',
				url: '/api/diyview/info',
				data: {
					name: 'DIYVIEW_INDEX'
				},
				success: res => {
					// this.goodsList = res.goods_list;
					if (res.code == 0 && res.data) {
						this.goodsList = res.goods_list;
					}
				}
			});
		},
		toDetail(e) {
			console.log("看一下",e.sku_id)
			this.$util.redirectTo('/pages/goods/detail/detail', { sku_id: e.sku_id });
		}
	}
};
</script>

<style lang="scss"></style>
